package com.vislardo.app.notebook.utils;

public class StrLableUtil {
    
    private static final char[] CHAR_32="0123456789ABCDEFGHKLMNPQRSTUWXYZ".toCharArray();
    private static final char[] CHAR_26="ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();

    public static String nsChange(long number,int numbersys){
        if(numbersys>32||numbersys<2|| numbersys == 10) return Long.valueOf(number).toString();
        long num = Math.abs(number);
        StringBuilder stringbuilder = new StringBuilder();
        while(num>0){
            //右端余数不会大于32，强制转换
            int remainder = (int) (num%numbersys);
            stringbuilder.insert(0,CHAR_32[remainder]);
            num /=numbersys;
        }
        return stringbuilder.toString();
    }
    public static String nsChange_2(long number){
        return nsChange(number,2);
    }
    public static String nsChange_8(long number){
        return nsChange(number,8);
    }
    public static String nsChange_16(long number){
        return nsChange(number,16);
    }
    public static String nsChange_32(long number){
        return nsChange(number,32);
    }
    public static String nsChange_Letter(long number){
        long num = Math.abs(number);
        StringBuilder stringbuilder = new StringBuilder();
        while(num>0){
            //右端余数不会大于32，强制转换
            int remainder = (int) (num%26);
            stringbuilder.insert(0,CHAR_26[remainder]);
            num /=26;
        }
        return stringbuilder.toString();
    }
}
